<template>
	<div>
		<van-nav-bar title="地址列表" left-arrow @click-left="onClickBack" @click-right="onClickRight">
			<template #right>
				<van-icon name="plus" size="18" />
			</template>
		</van-nav-bar>
		<div>
			<van-cell center  is-link v-for="(item,index) in  address_list" :key="index+''"  :to="{name:'editorAddress',query:{item}}">
				<template #title>
				      <div class="d-flex">
						    <div>{{item.name}}</div>
							<div>{{item.phone}}</div>
					  </div>
				</template>
				<template #label>
					<div>
						<span class="custom-title">{{item.province}}</span>
						<span class="custom-title">{{item.city}}</span>
						<span class="custom-title">{{item.district}}</span>
					</div>
				    <div>
						<span class="custom-title">{{item.address}}</span>
					</div>
				</template>
			</van-cell>
		</div>
	</div>
</template>

<script>
	import {
		addressList,
		useraddress
	} from '../lib/address.js'
	export default {
		data() {
			return {
				address_list:[]
			}
		},
		created() {
			this.getList()
		},
		methods: {
			getList(page = 1) {
				addressList({
					page: page
				}).then(res => {
					if(res.msg==='ok'){
						this.address_list= res.data
					}
					console.log(res)
				})
			},
			onClickBack() {
				this.$router.go(-1)
			},
			onClickRight() {
				this.$router.push({
					name:"editorAddress"
				})
			},
		}
	}
</script>

<style>
</style>
